<form class="layui-form">
  <div class="layui-form-item">
    <label class="layui-form-label">订单日期</label>
    <div class="layui-input-inline">
      <input class="layui-input" name="add_time" value="{$info['add_time']|date='Y-m-d H:i:s',###}" id="LAY_demorange_ss">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">归属店铺</label>
	<div class="layui-input-inline">
      <select name="depart_id" lay-filter="staff" lay-verify="required">
        <option value="">请选择{$info['depart_id']}</option>
        <volist name="door" id="vo">
            <option value="{$vo.depart_id}" <if condition="$info['depart_id'] eq $vo['depart_id']">selected</if>>{$vo.depart_name}</option>
        </volist>
      </select>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">销售导购</label>
	<div class="layui-input-inline">
      <select name="staff_id" id="staff_id" lay-verify="required">
        <option value="{$info.staff_id|default=0}">{$info.staff_name|default='系统销售'}</option>
      </select>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">订单类型</label>
	<div class="layui-input-inline">
      <select name="offline_status" lay-verify="required">
        <option value="0" <if condition="$info.offline_status eq 0">selected</if>>线上</option>
        <option value="2" <if condition="$info.offline_status eq 2">selected</if>>线下</option>
        <option value="1" <if condition="$info.offline_status eq 1">selected</if>>待定</option>
      </select>
    </div>
  </div>
    <div class="layui-form-item">
    <label class="layui-form-label">线下取货</label>
    <div class="layui-input-block">
      <volist name="list" id="vo">
          <input name="goods_id[{$vo.goods_id}]" title="{$vo.goods_name}" <if condition="$vo.get_way eq 1">checked=""</if> type="checkbox">
      </volist>
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="user">更新</button>
    </div>
  </div>
  <input type="text" name="order_id" value="{$info['order_id']}" style="display:none;"/>
</form>
<script>
layui.use(['upload','form', 'layedit', 'laydate'], function(){
    var form = layui.form()
    ,layer = layui.layer
    ,layedit = layui.layedit
    ,laydate = layui.laydate
    ,upload  = layui.upload
    ,$ = layui.jquery;
    form.on('select(staff)', function(data){
    	var url = "{:U('Bill/staffList')}";
        var val = data.value;
        $("#staff_id").empty();
    	$.get(url,{id:val},function(data){
            $("#staff_id").append(data);
            form.render();
        });
    }); 
  
	  form.on('submit(user)', function(data){
		  
	    var userInfo = data.field;
	    
		var url = "{:U('Bill/changeStatus')}";
		$.post(url,userInfo,function(data){
        	//alert(data);
        	//return;
			if(data.status == 'error'){
				  layer.msg(data.msg,{icon: 5});//失败的表情
				  return;
			  }else if(data.status == 'success'){
				  layer.msg(data.msg, {
					  icon: 6,//成功的表情
					  time: 1000 //2秒关闭（如果不配置，默认是3秒）
					}, function(){
					   //location.reload();
                                           layer.closeAll();
					}); 
			  }
		})
	    return false;//阻止表单跳转
	  });
      
      //查看图片
	$(document).delegate('#back_img_str2','click',function(){
    	var src = $('#back_img_str').val();
		layer.open({
  			title: '查看图片'
  			,content: '<img width="276" height="276" src="'+src+'">'
		});   
	});
    // 重新选择图片
	$(document).delegate('.imageChange','click',function(){
		$('#back_img').show();
		$('#back_img1').hide();
	});
	layui.upload({
  		url: "{:U('Style/upload')}"
		,ext: 'jpg'
  		,success: function(res){
        	if(res.code==200){
            	$('#back_img').hide();
				$('#back_img1').show();
				$('#back_img_str').val(res.name);
            }
            if(res.code==400){
            	layer.msg(res.msg,{icon: 5});//失败的表情
				return;
            }
  		}
	});
	
    
var start = {
    min: '2000-01-11 23:59:59'
    ,max: '2099-06-16 23:59:59'
    ,istoday: false
    ,istime:true
    ,format: 'YYYY-MM-DD hh:mm:ss', 
  };
  document.getElementById('LAY_demorange_ss').onclick = function(){
    start.elem = this;
    laydate(start);
  }
  form.render(); 
});
</script>